What is best way to remove duplicate lines matching regex from string using Python